// map的作用是 遍历整个数组 并对每一项处理 把处理的结果存储到新的数组中返回
const map = (array, fn) => {
  let results = [];
  for (let value of array) {
    results.push(fn(value));
  }
  return results;
}

let a = map([1, 2, 3, 4], (item) => item * 2);
console.log(a);